import 'package:flutter/cupertino.dart';
import 'package:imember/Util/Global.dart';
import 'package:imember/Util/MyColor.dart';
import 'package:imember/Util/PageUtil.dart';
import 'package:imember/Widget/MyButton.dart';
import 'package:imember/Widget/MyDialog.dart';
import 'package:imember/Widget/MyImage.dart';
import 'package:imember/Widget/MyInput.dart';

class ShipmentDetail extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _ShipmentDetail();
  }
}

class _ShipmentDetail extends State {
  List<String> boxlist = ["豬腳貢糖X10，原味貢糖X10", "豬腳貢糖X10"];

  @override
  Widget build(BuildContext context) {
    List<Widget> boxWidgets = [];
    for (var i = 0; i < boxlist.length; i++) {
      boxWidgets.add(box("第${i + 1}箱", boxlist[i]));
    }
    return Container(
        color: MyColor.White,
        child: Column(mainAxisSize: MainAxisSize.min, children: [
          Row(children: [
            LocalImage("ic_back_g.png", width: 48, onTap: () {
              PageUtil().back(context);
            })
          ]),
          Expanded(
              child: SingleChildScrollView(
                  padding: EdgeInsets.fromLTRB(0, 0, 60, 0),
                  child: Column(children: [
                    Container(height: 16),
                    Row(children: [
                      Expanded(child: Info("訂單編號", "123")),
                      Expanded(child: Info("發票號碼", "2134")),
                    ]),
                    Container(height: 16),
                    Row(children: [
                      Expanded(child: Info("出貨時間", "2020/12/23 14:43")),
                      Expanded(child: Info("出貨方式", "機場")),
                    ]),
                    Container(height: 16),
                    Row(children: [
                      Expanded(child: Info("打包方式", "分開打包")),
                      Expanded(child: Info("顧客　　", "林XX")),
                    ]),
                    Container(height: 16),
                    Row(children: [
                      Expanded(child: Info("電話　　", "0921345676")),
                      Expanded(child: Info("導遊　　", "林XX")),
                    ]),
                    Container(height: 16),
                    Info("地址　　", "金門縣"),
                    Container(height: 16),
                    Column(
                      children: boxWidgets,
                    ),
                    Container(height: 3, color: MyColor.Orange, margin: EdgeInsets.fromLTRB(35, 30, 0, 17)),
                    box("出貨明細", "豬腳貢糖20，原味貢糖X10"),
                    Container(
                        alignment: Alignment.centerRight,
                        child: OrangeBtn("出貨", width: 170, height: 37, margin: EdgeInsets.fromLTRB(0, 22, 0, 20)))
                  ])))
        ]));
  }
}

class Info extends StatelessWidget {
  String title;
  String value;

  Info(this.title, this.value);

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Container(width: 60),
        Text(title, style: TextStyle(fontSize: 20, color: MyColor.C51)),
        Expanded(
            child: Container(
                height: 37,
                alignment: Alignment.centerLeft,
                margin: EdgeInsets.only(left: 12),
                padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
                decoration: Global.getBoxBg(20, MyColor.F5),
                child: Text(value, style: TextStyle(fontSize: 17, color: MyColor.C51))))
      ],
    );
  }
}

class box extends StatelessWidget {
  String title;
  String content;

  box(this.title, this.content);

  @override
  Widget build(BuildContext context) {
    return Container(
        color: MyColor.F5,
        margin: EdgeInsets.only(top: 13, left: 60),
        padding: EdgeInsets.all(20),
        width: double.infinity,
        child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
          Text(title, style: TextStyle(fontSize: 15, color: MyColor.Orange)),
          Container(height: 12),
          Text(content, style: TextStyle(fontSize: 17, color: MyColor.C51)),
        ]));
  }
}
